package cn.jobstart.controller;

import cn.jobstart.dto.ResumeWorkExperienceDTO;
import cn.jobstart.dto.ResumeWorkExperiencePageDTO;
import cn.jobstart.es.service.IResumeEsService;
import cn.jobstart.export.ResumeWorkExperienceDomainExport;
import cn.jobstart.modelExt.ResumeWorkExperienceExt;
import cn.jobstart.pubInter.IBaseService;
import cn.jobstart.pubInter.exception.SkException;
import cn.jobstart.searchExt.ResumeWorkExperienceSearchExt;
import cn.jobstart.service.IResumeWorkExperienceService;
import cn.jobstart.vo.ResumeWorkExperienceDetailDomainVO;
import cn.jobstart.vo.ResumeWorkExperienceDetailVO;
import cn.jobstart.vo.ResumeWorkExperienceDomainVO;
import cn.jobstart.vo.ResumeWorkExperienceListVO;
import cn.jobstart.web.common.SkJsonResult;
import io.swagger.annotations.Api;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.HashSet;
import java.util.Set;

/**
 * @author sunke
 * @Date 2023-09-06 15:00:21
 * @description ResumeWorkExperienceController      工作经历
 */
@Api(tags = "人才管理系统-工作经历相关", description = "工作经历相关接口")
@RestController(value = "resumeWorkExperienceRestfulController")
@RequestMapping("/resumeWorkExperience/")
@Validated
public class ResumeWorkExperienceController extends ApiManageController<ResumeWorkExperienceDTO, ResumeWorkExperiencePageDTO, ResumeWorkExperienceExt, ResumeWorkExperienceSearchExt, ResumeWorkExperienceDomainVO, ResumeWorkExperienceDetailDomainVO, ResumeWorkExperienceDetailVO, ResumeWorkExperienceListVO, String> {

    @Resource(name = "resumeWorkExperienceService")
    private IResumeWorkExperienceService resumeWorkExperienceService;

    @Resource
    private IResumeEsService resumeEsService;


    @Override
    public void afterPostMod(ResumeWorkExperienceDTO dto, ResumeWorkExperienceExt domain, SkJsonResult<ResumeWorkExperienceDetailVO> jsonResult, HttpServletRequest request, HttpSession session) throws SkException {
        super.afterPostMod(dto, domain, jsonResult, request, session);
        resumeEsService.publishResumeWorkExperienceByResumeId(domain.getResumesId());
    }

    @Override
    public void afterPostAdd(ResumeWorkExperienceDTO dto, ResumeWorkExperienceExt domain, ResumeWorkExperienceDetailVO resumeWorkExperienceDetailVO, HttpServletRequest request, HttpSession session) throws SkException {
        super.afterPostAdd(dto, domain, resumeWorkExperienceDetailVO, request, session);
        resumeEsService.publishResumeWorkExperienceByResumeId(domain.getResumesId());
    }

    @Override
    public IBaseService<ResumeWorkExperienceExt, ResumeWorkExperienceSearchExt, String> getBaseService() throws SkException {
        return resumeWorkExperienceService;
    }

    @Override
    public String getBaseRoute() {
        return "/resumeWorkExperience/";
    }

    /**
     * 当前模板名称
     *
     * @return
     */
    @Override
    public String getModelName() {
        return "工作经历";
    }

    @Override
    public Class exportExcelClass() {
        return ResumeWorkExperienceDomainExport.class;
    }

    @Override
    public Set<String> totalMapSet() {
        Set totalMapSet = new HashSet();
        totalMapSet.add("count(resume_work_experience.rwe_id) as countNum");
        return totalMapSet;
    }


}